//
//  STGoodsListController.m
//  CuiBoStore
//
//  Created by 崔博 on 16/12/12.
//  Copyright © 2016年 崔博. All rights reserved.
//

#import "STGoodsListController.h"
#import "STGoodsTopView.h"
#import "STProductGoodsListView.h"
#import "STProductDetailController.h"
@interface STGoodsListController ()

@property (nonatomic, strong) STGoodsTopView *topView;
@property (nonatomic, strong) STProductGoodsListView *listView;
@end

@implementation STGoodsListController

- (void)viewDidLoad {
 
    [super viewDidLoad];
    
    [self.view addSubview:self.topView];
    [self.view addSubview:self.listView];
}
#pragma mark - event
// 跳转
- (void)pushVCGoodsID:(NSString *)goodsID
{
    STProductDetailController *detal = [[STProductDetailController alloc] init];
    detal.detailsGoodsId = goodsID;
    [self.navigationController pushViewController:detal animated:YES];
}
- (STGoodsTopView *)topView
{
    if (!_topView) {
        _topView = [[STGoodsTopView alloc] init];
        _topView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 30);
        _topView.block = ^(NSInteger index){
            
        };
    }
    return _topView;
}
- (STProductGoodsListView *)listView
{
    if (!_listView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        NSInteger itemW = SCREEN_WIDTH / 2 - 10;
        layout.itemSize = CGSizeMake(itemW, itemW * 0.725);
        _listView = [[STProductGoodsListView alloc]initWithFrame:CGRectMake(0, 30, SCREEN_WIDTH, self.view.height - 30) collectionViewLayout:layout];
        @weakify(self);
        _listView.block = ^(NSString *goodsID){
            [weak_self pushVCGoodsID:goodsID];
        };
        _listView.backgroundColor = BACKGROUND_COLOR;
        _listView.dataList = _dataList;
    }
    return _listView;
}
@end
